<?php

/**
 * Class Account_Form_Login
 * This class allows Users of the application Login
 */

 class Account_Form_Login extends Zend_Dojo_Form {
	
	public function __construct($options = null)
		{
		parent::__construct($options);
		Zend_Dojo::enableForm($this);
		$this->setName('Login');
		$this->setLegend('Login');
		
		/**Testing the decorators
		$decorators = array (
						array ('ViewHelper'),
						array ('Errors'),
						array ('Label', array (
						'requiredSuffix' => '*')));
	
						*/
		
$frontController = Zend_Controller_Front::getInstance();
$base = $frontController->getBaseUrl();
$req =new Zend_Controller_Request_Http();
$hostname = $req->getHttpHost();

$this->addElement('hidden', 'return', array(
          'value' => "http://" .$hostname . $frontController->getRequest()->getRequestUri()
));
		
		$username = new Zend_Dojo_Form_Element_ValidationTextBox('username');
		$username->setLabel('username :')
		->setRequired(true)
		->addFilter('StripTags')
		->addFilter('StringTrim')
		->addValidator('NotEmpty');
		$password = new Zend_Dojo_Form_Element_PasswordTextBox('password');
		$password->setLabel('password :')
		->setRequired(true)
		->addFilter('StripTags')
		->addFilter('StringTrim')
		->addValidator('NotEmpty');
				
		$submit = new Zend_Dojo_Form_Element_SubmitButton('login');
		$this->addElements(array($username, $password, $submit));
		 // remove form HtmlTag decorator and add a fieldset tag
$this->setDecorators(array(
          'FormElements',
          array('HtmlTag', array('tag' => 'fieldset')),
          'Form'
      ));

$username->removeDecorator('Label');
$username->addDecorator('Label');
$username->removeDecorator('HtmlTag');
$username->addDecorator('HtmlTag', array('tag' => 'p'));
//Removes dt tags
$password->removeDecorator('Label');
$password->addDecorator('Label');
$password->removeDecorator('HtmlTag');
$password->addDecorator('HtmlTag', array('tag' => 'p'));
		
		$this->setMethod('post');
		$this->setAction(Zend_Controller_Front::getInstance()->getBaseUrl().'/account/users/login');
		}
}